import cv2
from cv2 import cornerSubPix
from matplotlib.pyplot import gray
import numpy as np

# tomasi
maxCorners = 1000
qualityLevel = 0.01
minDistance = 10  # 距离越大，检测的角数越少

img = cv2.imread("E:\\chess.png")

# 灰度化
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

corners = cv2.goodFeaturesToTrack(gray, maxCorners, qualityLevel, minDistance)
corners = np.int0(corners)  # 将浮点型转换为整型

# shi_Tomasi 绘制角点
for i in corners:
    x,y = i.ravel()  #转换为一维数组
    cv2.circle(img, (x,y), 3, (0,0,255),-1)

cv2.imshow('shi_Tomasi',img)
cv2.waitKey(0)